package com.carleasoft.mps.cms.business.collector.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.carleasoft.mps.cms.business.message.bean.po.StatisticalAnalysisMessageNotePo;
import com.carleasoft.mps.cms.business.message.service.MessageNoteService;
import com.carleasoft.mps.cms.business.resource.bean.vo.WebCountVo;
import com.carleasoft.mps.cms.business.resource.service.ReasourceService;
import com.carleasoft.mps.cms.business.train.bean.entity.TrainExam;
import com.carleasoft.mps.cms.business.train.bean.entity.TrainPlan;
import com.carleasoft.mps.cms.business.train.bean.po.StatisticalAnalysisConsumptionPo;
import com.carleasoft.mps.cms.business.train.service.TrainCarService;
import com.carleasoft.mps.cms.business.train.service.TrainExamService;
import com.carleasoft.mps.cms.business.train.service.TrainPlanService;
import com.carleasoft.mps.core.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: yangHao
 * @createDate:2023/6/27
 * @description:
 */
@RestController
@RequestMapping("/eipCar")
public class EipCarController {
    @Autowired
    private MessageNoteService messageNoteService;
    @Autowired
    private TrainPlanService trainPlanService;
    @Autowired
    private TrainExamService trainExamService;
    @Autowired
    private ReasourceService reasourceService;
    @Autowired
    private TrainCarService trainCarService;
    /**
     * 统计分析-心理和法律援助
     */
    @PostMapping("/statisticalAnalysis/messageNote")
    public R statisticalAnalysisMessageNote(@RequestBody StatisticalAnalysisMessageNotePo statisticalAnalysisMessageNotePo) {
        return R.ok(messageNoteService.statisticalAnalysisMessageNote(statisticalAnalysisMessageNotePo));
    }

    /**
     * 训练计划-列表（条件查询）
     */
    @PostMapping("/trainPlanListByParam")
    public R<List<TrainPlan>> trainPlanListByParam(@RequestBody TrainPlan trainPlan) {
        QueryWrapper<TrainPlan> queryWrapper = new QueryWrapper<TrainPlan>().eq("STATUS", 2).orderByDesc("CREATE_TIME");
        if (trainPlan.getTrainType() != null) {
            queryWrapper.eq("TRAIN_TYPE", trainPlan.getTrainType());
        }
        return R.ok(trainPlanService.list(queryWrapper));
    }

    /**
     * 训练考核-列表查询
     */
    @PostMapping("/trainExamList")
    public R<List<TrainExam>> trainExamList(@RequestBody TrainExam trainExam) {
        QueryWrapper<TrainExam> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("UPDATE_TIME");
        queryWrapper.eq("STATUS", 2);
        return R.ok(trainExamService.list(queryWrapper));
    }

    /**
     * web-教学资源概况
     *
     * @return
     */
    @PostMapping("/webCount")
    public R webCount() {
        List<WebCountVo> webCountVos = reasourceService.webCount();
        return R.ok(webCountVos);
    }

    /**
     * 统计分析-消耗情况-单位查询
     */
    @PostMapping("/statisticalAnalysis/dept")
    public R statisticalAnalysisDept() {
        return R.ok(trainCarService.statisticalAnalysisDept());
    }

    /**
     * 统计分析-消耗情况
     */
    @PostMapping("/statisticalAnalysis/consumption")
    public R statisticalAnalysisConsumption(@RequestBody StatisticalAnalysisConsumptionPo statisticalAnalysisConsumptionPo) {
        return R.ok(trainCarService.statisticalAnalysisConsumption(statisticalAnalysisConsumptionPo));
    }

    /**
     * 统计分析-训练档案-训练计划统计
     */
    @PostMapping("/trainingArchives/planStatistics")
    public R trainingArchivesPlanStatistics() {
        return R.ok(trainPlanService.trainingArchivesPlanStatistics());
    }

}
